package xyz.chaobei.jpa;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import xyz.chaobei.jpa.model.OrgUser;
import xyz.chaobei.jpa.reposity.OrgUserRepository;

@SpringBootApplication
public class JpaApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(JpaApplication.class, args);
    }

    @Autowired
    private OrgUserRepository orgUserRepository;

    @Override
    public void run(String... args) throws Exception {

        System.out.println("Application is running!");

        OrgUser findId = orgUserRepository.findById(13).get();
        System.out.println("find findById=" + findId);

        OrgUser desc = orgUserRepository.findOrgUserByUsernameAndPassword("UserName0","PassWord0");
        System.out.println("find findOrgUserByUsernameAndPassword=" + desc);


        OrgUser one = orgUserRepository.selectById(13);
        System.out.println("find selectById=" + one);

        Iterable<OrgUser> all = orgUserRepository.findAll();
        System.out.println(all);

    }
}
